package com.physics.mps.module.compute;

import com.physics.mps.entity.vo.ResponseResult;
import com.physics.mps.entity.vo.StartComputeVo;
import com.physics.mps.module.fastcae.vo.FastcaeMeshData;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author mcsoft
 * @since 2023/8/26
 */
@Slf4j
@RestController
@RequestMapping("/compute")
@RequiredArgsConstructor
public class ComputeController {


    // ~ Variable & Constant
    // ========================================================================================================


    // ~ Public method
    // ========================================================================================================

    @PostMapping(value = "/startCompute")
    public ResponseResult startCompute(@RequestBody @Validated StartComputeVo startComputeVo) throws Exception {
        return ComputeService.compute(startComputeVo);
    }

    @PostMapping(value = "/runOdbToVtu/{subTaskId}")
    public ResponseResult runOdbToVtu(@PathVariable("subTaskId") String subTaskId) throws Exception {
        return ComputeService.runOdbToVtu(subTaskId);
    }


    @PostMapping(value = "/fastCaeCompute")
    public ResponseResult fastCaeCompute(@RequestBody @Validated StartComputeVo startComputeVo) throws Exception {
        return ComputeService.fastCaeCompute(startComputeVo);
    }

    @PostMapping(value = "/fastCaeMesh")
    public ResponseResult fastCaeMesh(@RequestBody @Validated FastcaeMeshData meshData) throws Exception {
        return ComputeService.fastCaeMesh(meshData);
    }

    @PostMapping(value = "/openfoamCompute")
    public ResponseResult openfoamCompute(@RequestBody @Validated StartComputeVo startComputeVo) throws Exception {
        return ComputeService.openfoamCompute(startComputeVo);
    }

    @PostMapping(value = "/uOpenfoamCompute")
    public ResponseResult uOpenfoamCompute(@RequestBody @Validated StartComputeVo startComputeVo) throws Exception {
        return ComputeService.uOpenfoamCompute(startComputeVo);
    }

    // ~ Override method
    // ========================================================================================================


    // ~ Private method
    // ========================================================================================================


    // ~ Autowired
    // ========================================================================================================

    private final ComputeServiceImpl ComputeService;

}
